package com.consul.config;


import com.consul.controller.LoginAuth;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.annotation.Annotation;

/**
 * @author yinxing
 * @date 2022-08-15
 */
@Slf4j
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("=============前置方法============");
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        LoginAuth loginRequired = handlerMethod.getMethodAnnotation(LoginAuth.class);
        if (loginRequired == null) {
            log.info("===============不需要权限校验==============");
        }else {
            log.info("===============需要权限校验==============");
        }
        return false;
    }
}
